#include <stdio.h>
#include "code.h"
#define len 5


// double y_input[] ={1,12,23,46,78,98,100,123,160,210,230,270,292,350,346,386,438,349,460,512};
// 数据1，x由为 1:1:20; 由1出发，1个步长，到20


// double y_input[] = {-0.447, 1.978, 3.28, 6.16, 7.08, 7.34, 7.66, 9.56, 9.48, 9.30, 11.2};
// 数据2, x为：0.1:0.1:1; 0.1出发，0.1个步长，到1

// double y_input[] = {2.7  ,  7.4  ,  20.0  ,  54.5  ,  148.4};

double y_input[] = {2.7 , 2.7 , 2.7 , 2.7 , 2.7};


void create_test(double * x_test , double * y_test , double * w_test){
    int i;

    for ( i = 0 ; i < 5 ; i++){
        // x_test[i] = ((double)(i)) / 10.0;
        x_test[i] = (double)(i+1);
        // y_test[i] = 2.0* x_test[i] * x_test[i] + 4.0;//方程 f(x) =  2*i^2 + 4

        y_test[i] = y_input[i];
        
        w_test[i] = 1.0; // 测试部分，权重先设置为1
        printf ( "| x : %le | y : %le | w : %le |\n " , x_test[i] , y_test[i] , w_test[i]);

    }
}

int main(){
    double *temp;
    double x_test[len] , y_test[len] , w_test[len];
    
    create_test(x_test , y_test , w_test);

    
    
    polyfit(x_test , y_test , w_test , 0 , len);

    // int i;
    // for (i = 0; i<2;i++){
    //     printf("| %f |" , temp[i]);
    // }
}